﻿@model BabyShop.WebSite.Models.Actions

@{
    ViewBag.Title = @Model.ActionGuid == Guid.Empty ? "Create Action" : "Edit Action";
}
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    
@using (Ajax.BeginForm("Create", null, new AjaxOptions { HttpMethod = "post", OnSuccess = "CreateSucc",
    OnFailure = "CreateFailure" }, new { id = "CreateForm" })) {
        @Html.ValidationSummary(true)
        <fieldset class="FormFieldset">
            <legend>@ViewBag.Title</legend>
    
            <div class="editor-label">
                @Html.LabelFor(model => model.ActionName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ActionName)
                @Html.ValidationMessageFor(model => model.ActionName)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.ControllerName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.ControllerName)
                @Html.ValidationMessageFor(model => model.ControllerName)
            </div>
            <div class="editor-label">
                @Html.LabelFor(model => model.AreaName)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.AreaName)
                @Html.ValidationMessageFor(model => model.AreaName)
            </div>
        </fieldset>
        <div style="text-align: right;">
            <p>
                @Html.ActionLink("返回", "Index", null, new { id = "btnBack" })
                <input id="btnSubmit" type="submit" value="保存" />
            </p>
        </div>
        @Html.HiddenFor(m => m.ActionGuid)
    }
@section HeaderScript{
<script type="text/javascript">
    function CreateSucc(data, status) {
        if (status == 'success') {
            if (data.ErrorCode != 0)
                alert(data.ShowMsg);
            else {
                $.bs.showMsg('提示', data.ShowMsg);
                parent.window.frames[$.removePrefix($.sysRes.iframeName)].$('#btnSearch').click();
                $.bs.closeDialog();
            }
        }
    }

    function CreateFailure() {
        alert("Create failure.");
    }

    $(function () {
        $('#btnSubmit').button();
        $("#btnBack").button().click(function () {
            $.bs.closeDialog();
            return false;
        });
    });
</script>
}